package info.bond.rp.experiments;

/**
 * @author Andrey Bondarenko
 * 
 * Pair of values needed for generator - maximum index value 
 * for parameter and current one, plus functionality for iteration on values.
 */
public class MaxValueIndexPair {
	
	private Integer valueIndex;
	private Integer maxValueIndex;
	
	// Constructor
	public MaxValueIndexPair(Integer maxValueIndex, Integer valueIndex) {
		super();
		this.maxValueIndex = maxValueIndex;
		this.valueIndex = valueIndex;
	}
	
	public MaxValueIndexPair(Integer maxValueIndex) {
		this(maxValueIndex, 0);
	}
	// Business methods
	public Boolean isLastIndex() {
		return valueIndex.equals(maxValueIndex - 1);
	}
	public void increaseValueIndex() {
		if (isLastIndex()) {
			throw new IllegalArgumentException("Cannot increase valueIndex, because it is last!");
		}
		valueIndex++;
	}
	public void resetValueIndex() {
		valueIndex = 0;
	}
	// Getters/Setters
	public Integer getValueIndex() {
		return valueIndex;
	}
	public void setValueIndex(Integer valueIndex) {
		this.valueIndex = valueIndex;
	}
	public Integer getMaxValueIndex() {
		return maxValueIndex;
	}
	public void setMaxValueIndex(Integer maxValueIndex) {
		this.maxValueIndex = maxValueIndex;
	}
}
